package util;

import java.util.Arrays;

public class PasswordUtils {
    // 比较两个密码字符串是否一样，不考虑大小写
    public static boolean checkPassword(String password1, String password2) {
        if (password1 == null || password2 == null) {
            return false;
        }
        char[] pw1 = new char[password1.length()];
        Arrays.fill(pw1, '0');
        char[] pw2 = new char[password2.length()];
        Arrays.fill(pw2, '0');

        try {
            pw1 = password1.toCharArray();
            pw2 = password2.toCharArray();
            return Arrays.equals(pw1, pw2);
        } finally {
            // 清理密码字符数组
            Arrays.fill(pw1, '0');
            Arrays.fill(pw2, '0');
        }
    }
}